
#include "Screen.h"
#include <ostream>

using namespace std;


char Screen::get(Screen::index ht, Screen::index wd) const{
	return this->_content[ht * _width + wd];
}

// With inline : Error LNK2019: unresolved external symbol "public: unsigned int __thiscall Screen::get_cursor(void)const " (?get_cursor@Screen@@QBEIXZ) referenced in function _main
/*
inline Screen::index Screen::get_cursor() const{
	return _cursor;
}
*/
Screen& Screen::set(char ch){
	_content[_cursor] = ch;
	return *this;
}

Screen& Screen::move(index r, index c){
	index row = r * _width;
	_cursor = row + c;
	return *this;
}

Screen& Screen::set(Screen::index r, Screen::index c, char ch){
	_content[r * _width + c] = ch;
	return *this;
}

Screen& Screen::display(ostream &os){
	// os << "non-const display: " << _content << endl;
	do_display(os);
	return *this;
}
const Screen& Screen::display(ostream &os) const{
	// os << "const display: " << _content << endl;
	do_display(os);
	// _width = 1; // expression must be a modifiable lvalue
	_access_ctr ++;
	return *this;
}